/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, { Component } from 'react';
import { AppRegistry, Text, Image, View, StyleSheet, Navigator, TouchableOpacity } from 'react-native';


export default class TestNavigator extends Component<Props> {

    configureScene(route, routeStack) {
        return Navigator.SceneConfigs.PushFromRight;
    }

    render() {
        return (
            <Navigator
                style={{flex: 1}}
                initialRoute={{component: FirstPage}}
                configureScene={this.configureScene}
                renderScene={(route, navigator) => <route.component navigator={navigator} {...route.passProps} />}/>
        );
    }
}
// 首页
class FirstPage extends Component
{
    render()
    {
        return (
            <View>
                <TouchableOpacity onPress={() => this.props.navigator.push({component: SecondPage})}>
                    <Text style={{fontSize:28}}>点击跳转到二级页面</Text>
                </TouchableOpacity>
            </View>
        );
    }
}

// 二级页面
class SecondPage extends Component
{
    render()
    {
        return (
            <View>
                <TouchableOpacity onPress={()=>this.props.navigator.pop()}>
                    <Text style={{color: 'red', fontSize: 28}}>点击返回首页</Text>
                </TouchableOpacity>
            </View>
        );
    }

}


